<?php 

$oid = $_GET['listing_id'];
$mquery = "select p.* from PROPERTIES p where p.OID = '".$oid."'";
$mresult = mysql_query($mquery) or die ("SQL Error".mysql_error());
$prow = mysql_fetch_assoc($mresult);
if($prow['UNITFLOORNUM'] !='')
{
	$unit = " ".$prow['UNITFLOORNUM'];
}
else
{
	$unit = '';
}
$full_address = $prow['STREETNUM']." ".$prow['STREETDIR']." ".$prow['STREETNAME']." ".$prow['STREETSUFFIX']."".$unit.", ".$prow['CITY']." ".$prow['STATE']." ".$prow['ZIPCODE'];

$query = "Select * from VT_Config where Listing_ID = '".$oid."'";
$result = mysql_query($query) or die ("SQL Error".mysql_error());
$rowv = mysql_fetch_assoc($result);
?>

<table bgcolor="#666666" style=" color:#999999; border-top:1px solid black; border-bottom:1px solid black; font-family:Arial, Helvetica, sans-serif" align="center" width="100%" border="0" cellspacing="0" cellpadding="0">
			<TR>
				<TD align="center" style="padding:2px 0px 2px 20px; height:20px;">
					<table width="825" border="0" cellspacing="1" cellpadding="1">
						  <tr>
							<td align="left" style="color:#FFFFFF; font-size:18px;">
							<?php echo $full_address ?> | 
							Asking Price: $<?php echo number_format($prow['LISTPRICE'], 0) ?>
							</td>
						  </tr>
						</table>
				</TD>
			</TR>
		</Table>
<center>
<table width="800" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>

<!--Main Page-->
<BR />
<?php

require(ABS_PATH.'realivent_functions.php');

$asql = "Select * from Users u inner join Prop_Owner_Con c on c.Owner = u.ID where c.Prop_OID = '".$oid."'";
			
			$aresult = mysql_query($asql) or die ("SQL Error".mysql_error());
			$arow=mysql_fetch_assoc($aresult);

if(isset($_POST['submit']))
{
	// To send HTML mail, the Content-type header must be set
			$headers  = 'MIME-Version: 1.0' . "\r\n";
			$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
			
			// Additional headers
			$headers .= 'From:'.$_POST['name']."<".$_POST['email']."> \r\n";
			$message = "<strong>Full Name:</strong> ".$_POST['name']."<BR>";
			$message .= "<strong>Email:</strong> ".$_POST['email']."<BR>";
			$message .= "<strong>Phone:</strong> ".$_POST['phone']."<BR>";
			$message .= "<strong>Department:</strong> ".$_POST['department']."<BR>";
			$message .= "<BR><strong>Message:<BR></strong> ".$_POST['message']."<BR>";
			
			$to = $arow['Email'];
			$subject = 'Contact message sent from Realivent.com';
			$body = $message;
			mail($to, $subject, $body, $headers);
			$response = 'Message has been sent, <BR>we will be contacting you shortly.';
}
?>
	
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		
			  <tr>
				<td align="left" >
				<table width="800" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td style="padding:0px 0px 0px 10px;" width="430px">
			<?php 
			if($response != '')
			{
				echo '<BR><BR>'.$response;
			}
			else
			{
			?>
			<form action="contact.php?listing_id=<?php echo $oid ?>" method="post" name="theform">
			<table style="border:1px solid #999999;" width="790" border="0" cellspacing="2" cellpadding="2">
				<TR>
					<TD bgcolor="#EDF3F3" colspan=3 style="font-size:12px; padding:3px;">
						<div style="float:left; padding-left:10px;">
				<div style="float:left;"><strong><?php echo $arow['First_Name'] ?> <?php echo $arow['Last_Name'] ?></strong> | </div>
				<div style="float:left;"><strong>&nbsp;Phone: </strong><?php echo $arow['Phone'] ?> | </div>
				<div style="float:left;"><strong>&nbsp;Email: </strong><a href=mailto:<?php echo $arow['Email'] ?>><?php echo $arow['Email'] ?></a> | </div>
				<div style="float:left;"><strong>&nbsp;Website: </strong><a target="_blank" href=http://<?php echo $arow['Website'] ?>><?php echo $arow['Website'] ?></a></div>
						</TD>
				</TR>
			  <tr>
				<td valign="top">
					<?php 
					/* agent information */
					
					?>
					<DIV style="padding-top:10px;">
					<div>
					<?php if ($arow['Image']!='')
					{ ?>
					<img src='<?php echo SITE_ROOT_URL?>user_images/t75_<?php echo $arow['Image'] ?>'>
					<?
					}
					else
					{
						?>
						
						
						<?
					}
					?>
					</div>
					<div style="padding-top:5px;">
					<?php if ($arow['Company_Logo']!='')
					{ ?>
					<img src='<?php echo SITE_ROOT_URL?>user_images/t_<?php echo $arow['Company_Logo'] ?>'>
					<?
					}
					else
					{
						?>
						<?
					}
					?>
					</div>
				</td>
				<TD valign="top" align=center>
				
					<?php 
					if($arow['Mantra'] !='')
					{
					?>
					<div style="text-align:left; padding:30px;">"<?php echo $arow['Mantra'] ?>"</div>
					<?php 
					}
					else
					{
					?>
					<div style="text-align:le; padding:20px;">"Please contact me for any questions you have about real estate, I will provide you with the best possible service."</div>
					<?php 
					}
					?>
		
				</td>
				<TD style="padding:5px;">
	
	<table id=form width="390" border="0" cellspacing="4" cellpadding="4">
			  <tr>
				<th colspan="2" align="left">Send a Quick Message To <?php echo $arow['First_Name'] ?> <?php echo $arow['Last_Name'] ?></th>
			  </tr>
			  <tr>
				<td width=100 nowrap="nowrap" align="right">Full Name: </td>
				<td><input style="width:300px;" name="name" type="text"></td>
			  </tr>
			  <tr>
				<td align="right">Email: </td>
				<td><input style="width:300px;" name="email" type="text"></td>
			  </tr>
			  <tr>
				<td align="right">Phone: </td>
				<td><input style="width:300px;" name="phone" type="text"></td>
			  </tr>
			  
			  <TR>
			  	<TD colspan="2">
				Message:<BR>
				<textarea style="width:400px;" name="message" rows="5"></textarea>
			  </TR>
			  <TR>
			  	<TD colspan="2">
					<input name="submit" type="submit" value="Submit">
				</TD>
			  </TR>
			</table>
			</form>
	
	
				</td>
			  </tr>
			</table>

			
		
				
				</td>
				
			  </tr>
			 
			</table>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<TR>
					<TD colspan="2"><div style="font-size:18px; padding-top:10px;">Sign Up for Property Watch</div></TD>
				</TR>
			  <tr>
				<td><?php get_listing_watch_form();?></td>
				<TD width="300" valign="top" style="padding:5px;"><strong>Property watch is a great way to beat out other buyers to your next dream home. Just fill out the form with your search criteria and as soon as 
				that house hits the market you will get an email. It's completely free, and you can stop the service any time.</strong></TD>
			  </tr>
			</table>
	<?php 
			}
			?>
			
			

		  </tr>
		</table>